Skip to content

When $ref is present other keywords should be ignored #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 26, 2016

Conversation

pipobscure
Copy link

See answer by @Julian on #129

@Julian
Copy link
Member

Julian commented Dec 26, 2016

I was sure there was a test covering this already but it appears there isn't... thanks for submitting. Leaving some comments.

@@ -141,6 +141,32 @@
]
},
{
"description": "ref, containing other keywords",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be a bit clearer I think to say something like "ref overrides any sibling keywords" which is the behavior, rather than just describing the situation without explicitly pointing that out.

"properties": {
"foo": {
"$ref": "#/definitions/reffed",
"type": "integer"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it also might be clearer to pick an example that isn't just conflicting keywords. E.g., using type array behind a $ref but having a minLength will ignore the minLength sibling.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that's true anyway, isn't it?

"properties": {
    "foo": {
        "type": "array",
        "minLength": 10,
    }
}

validates "foo": [] and "foo": [1, "a", {}] but not "foo": "short" or "foo": "thisiswaytoolong"

because "minLength" can only fail validation against string instances. It has no effect on other types.

"valid": true
},
{
"description": "remote ref valid",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid

@pipobscure pipobscure force-pushed the refOnly branch 2 times, most recently from 7ed7f50 to e31fce9 Compare December 26, 2016 19:36
@pipobscure
Copy link
Author

Better? Is this what you meant?

@Julian
Copy link
Member

Julian commented Dec 26, 2016

Yes, nice work! Merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants